package com.kingwang.training.designpattern.chainofresponsibility.bo;

import lombok.Data;

import java.time.LocalDateTime;

/**
 * HR
 */
@Data
public class HrManager extends ApplicationApprover {
    public HrManager(String name) {
        super(name);
    }

    @Override
    public void handle(LeaveApplication application) {
        Double leaveDays = application.getLeaveDays();

        if (leaveDays > 2 && leaveDays <= 7) {
            application.setApprover(getName());
            application.setApproveTime(LocalDateTime.now());

            System.out.println("HR审批");
        } else {
            ApplicationApprover nextApprover = getNextApprover();
            if (nextApprover != null) {
                System.out.println("HR无权审批，转移至下一级");
                nextApprover.handle(application);
            }
        }
    }
}
